package com.jiang.smartdangjian.tool;

import android.content.Context;
import android.content.SharedPreferences;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.jiang.smartdangjian.R;
import com.jiang.smartdangjian.model.NewsData;


public class Tool {
    public static void loadImg(String url, ImageView imageView) {
        if (url != null) {
            Glide.with(imageView.getContext())
                    .load(HttpUtil.BASE_URL + url)
                    .error(R.drawable.ic_baseline_error_24)
                    .skipMemoryCache(true)
                    .into(imageView);
        }
    }

    public static SharedPreferences getSP(Context context) {
        return context.getSharedPreferences("app", Context.MODE_PRIVATE);
    }

    public static String getToken(Context context) {
        return getSP(context).getString("token", "");
    }

    public static String getUserId(Context context) {
        return getSP(context).getString("userId", "");
    }

    public static NewsData.RowsModel news;

}
